package cn.jetpiece.cloud.system.dp.app.core.handler;

import cn.jetpiece.cloud.datasource.core.metadata.JetpieceMetaObjectHandler;
import cn.jetpiece.cloud.core.context.LoginUserContext;
import cn.jetpiece.cloud.uc.auth.support.TenantContext;

public class SystemBpmMateObjectHandler extends JetpieceMetaObjectHandler {

    @Override
    protected Long getUserUniqueId() {
        String token = LoginUserContext.getInstance().getToken(false);
        if (token == null) {
            return 0L;
        }
        return LoginUserContext.getInstance().getUserId();
    }

    /**
     * 获取用户名
     */
    @Override
    protected String getUsername() {
        String token = LoginUserContext.getInstance().getToken(false);
        if (token == null) {
            return null;
        }
        return LoginUserContext.getInstance().getUsername();
    }

    /**
     * 获取逻辑删除字段的默认值
     */
    @Override
    protected Long getDefaultTenantIdValue() {
        return TenantContext.getTenant();
    }
}
